package com.xiaren.ui.edit;

import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.text.StyledEditorKit;

/**
 * 关于文本的所有监听
 * @author xiaren
 * @主页 http://www.leaf123.cn/
 * @邮箱 xia5523@qq.com
 *
 */
public class EditAction {

	/**
	 * 加粗监听
	 * @param btn
	 * @return
	 */
	public static Action addBoldAtion(JButton btn){
		Action boldAction = new StyledEditorKit.BoldAction();
		btn.setAction(boldAction);
		btn.setText("Bold");
		return boldAction;
	}
	/**
	 * 下划线监听
	 * @param btn
	 * @return
	 */
	public static Action addUnderLineAtion(JButton btn){
		Action underLineAction = new StyledEditorKit.UnderlineAction();
		btn.setAction(underLineAction);
		btn.setText("UnderLine");
		return underLineAction;
	}
	/**
	 * 倾斜监听
	 * @param btn
	 * @return
	 */
	public static Action addItalicAtion(JButton btn){
		Action italicAction = new StyledEditorKit.ItalicAction();
		btn.setAction(italicAction);
		btn.setText("Italic");
		return italicAction;
	}

}
